<include file="../header" />
<body class="J_scroll_fixed">

<script language="javascript" src="/Template/js/ImgPreview.js"></script>

<style type="text/css">
    .btn-danger,.btn-info,.btn-success,.btn-warning{
        width: 50px;
        /*height: 18px;*/
        padding: 2px 0px 2px 0px;
        margin: 1px 0px 1px 0px;
    }
    select{
        width: auto
    }
</style>
<script type="text/javascript">
    $(function() {

        $("input[name=checkAll]").click(function() {
            var checkboxs = $("input.checkItem");
            if($("input[name=checkAll]").is(':checked')) {
                for(var i = 0 ;i<checkboxs.length;i++) {
                    checkboxs[i].checked = true;
                }
            }else{
                for(var i = 0 ;i<checkboxs.length;i++) {
                    checkboxs[i].checked = false;
                }
            }
        });

        $("a[name=downloadExcel]").click(function() {
            var checkboxs = $("input.checkItem");
            var id = "";
            for (var i = 0; i < checkboxs.length; i++) {
                if(checkboxs[i].checked == true){
                    if(id != ""){
                        id += ",";
                    }
                    id += checkboxs[i].name;
                }
            }
            if(id == ""){
                alert("未选择单据");
                $("input[name=checkAll]").focus();
                return false;
            }
            var url = "/admin/Storage/getTable?id=" + id;
            window.location.href = url;
        });

        $("select[name='sr#type']").change(function () {
            if($("select[name='sr#type']").val() == ""){
                $("input[name='code-like']").val("");
                $("input[name='name-like']").val("");
                $("input[name='code-like']").attr("readonly","readonly");
                $("input[name='name-like']").attr("readonly","readonly");
            }else{
                $("input[name='name-like']").removeAttr("readonly");
                $("input[name='code-like']").removeAttr("readonly");
            }
        });

        if($("select[name='sr#type']").val() == ""){
            $("input[name='code-like']").val("");
            $("input[name='name-like']").val("");
            $("input[name='code-like']").attr("readonly","readonly");
            $("input[name='name-like']").attr("readonly","readonly");
        }else{
            $("input[name='name-like']").removeAttr("readonly");
            $("input[name='code-like']").removeAttr("readonly");
        }
    });
</script>
<form class="well form-search" method="post" style="float:left;width:100%;" action="{:U('Storage/index')}">
    <div class="search_type cc mb10">
        <div class="mb10">
        <span class="mr20">
            类型：
            <select style="width: 90px" class name="sr#type">
                {:getFormDictSelectOption($type,'storageType','all',1)}
            </select>
            &nbsp;&nbsp;
            收货仓：
            <select name="sr#store_id-eq">
                {:getCommonSelectOptionHtml($store_id, "Store", "store_id", "store_name", null, $user['enterprise_code'], 1)}
            </select>
            &nbsp;&nbsp;
            编码：<input type="text" name="code-like" value="{$code}" readonly/>
            &nbsp;&nbsp;
            名称：<input type="text" name="name-like" value="{$name}" readonly/>
            &nbsp;&nbsp;
            <button class="btn btn-primary">过滤</button>
            &nbsp;&nbsp;
            <a class="btn" href="{:U('Storage/index')}">重置</a>

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            每页显示：
            <select name="pageSize">
                <option value=''></option>
                <php>$selected=($pageSize == 50)?"selected":"";</php>
                <option value='50' {$selected}>50条</option>
                <php>$selected=($pageSize == 100)?"selected":"";</php>
                <option value='100' {$selected}>100条</option>
                <php>$selected=($pageSize == -1)?"selected":"";</php>
                <option value='-1' {$selected}>全部</option>
            </select>
        </span>
        </div>
    </div>
</form>
<div class="wrap J_check_wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a>相关信息</a></li>
        <li><a name="downloadExcel" style="cursor: pointer;">下载选中报表</a></li>
    </ul>
    <table class="table table-hover table-bordered">
        <thead>
        <tr>
            <th style="min-width: 10px; width: 10px"><input type="checkbox" name="checkAll"></th>
            <th style="min-width: 80px; width: 80px">编码</th>
            <th>名称</th>
            <th style="width: 60px">类型</th>
            <th style="width: 200px">规格型号</th>
            <th style="width: 70px">辅助属性</th>
            <th style="width: 70px">供货商</th>
            <th style="width: 100px">批号</th>
            <th style="width: 150px">条形码</th>
            <th style="min-width: 30px; width: 30px">单位</th>
            <th style="min-width: 40px; width: 40px">库存</th>
            <th style="min-width: 60px; width: 60px">单位成本</th>
            <th style="min-width: 60px; width: 60px">成本</th>
            <th style="width: 150px">仓库</th>
            <th style="width: 100px">生产日期</th>
            <th style="width: 100px">有效期至</th>
        </tr>
        </thead>
        <tbody>
        <foreach name="list" item="vo">
            <tr>
                <php>
                    if($vo["type"] == "定制矫形器"){
                        $vo["price"] = $vo["instore_price"];
                    }
                    $checkName = $vo["storage_id"];
                    $roundPrice = sprintf("%.2f", $vo["price"]);
                    $totalPrice = $vo["price"] * $vo["storage_number"];
                    $roundTotelPrice = sprintf("%.2f", $totalPrice);
                </php>
                <td><input type="checkbox" class="checkItem" name="{$checkName}"></td>
                <if condition="$vo['type'] eq '物料'">
                    <td>
                        {$vo.parent_name}.{$vo.code_name}
                    </td>
                    <td>{$vo.material_name}</td>
                    <td style="color:#45a1de;">{$vo.type}</td>
                    <td>{$vo.spec}</td>
                    <td>{$vo.prop}</td>
                    <td>{$vo.supplier_name}</td>
                    <td>{$vo.batch_no}</td>
                    <td>{$vo.material_barcode}</td>
                    <td>{$vo.material_unit}</td>
                </if>
                <if condition="$vo['type'] eq '成品矫形器'">
                    <td>
                        {$vo.finished_product_code}
                    </td>
                    <td>{$vo.finished_product_name}</td>
                    <td style="color:#1cc385;">{$vo.type}</td>
                    <td>{$vo.size}</td>
                    <td>{$vo.class_name}</td>
                    <td>{$vo.supplier_name}</td>
                    <td>{$vo.batch_no}</td>
                    <td>{$vo.finished_product_barcode}</td>
                    <td>{$vo.finished_product_unit}</td>
                </if>
                <if condition="$vo['type'] eq '定制矫形器'">
                    <td>
                        {$vo.customized_product_code}
                    </td>
                    <td>{$vo.inventory_name}</td>
                    <td style="color:#ffa476;">{$vo.type}</td>
                    <td>{$vo.instore_spec}</td>
                    <td></td>
                    <td>{$vo.supplier_name}</td>
                    <td>{$vo.instore_batch_no}</td>
                    <td>{$vo.instore_barcode}</td>
                    <td>{$vo.instore_unit}</td>
                </if>
                    <td>{$vo.storage_number}</td>
                    <td>{$roundPrice}</td>
                    <td>{$roundTotelPrice}</td>


                <td>{$vo.store_name}</td>
                <td>{$vo.production_date}</td>
                <td>{$vo.expiry_date}</td>
            </tr>
        </foreach>
        </tbody>
    </table>
    <div class="pagination">{$page}</div>
</div>
<script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>